﻿using Spider.Data;
using System.Web;
using System.Web.Mvc;

namespace Spider.Mvc
{
     class SmartModelBinder : IModelBinder
    {
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            HttpRequestBase req=controllerContext.HttpContext.Request;
            byte[] bytes=new byte[req.ContentLength];
            req.InputStream.Position = 0;
            req.InputStream.Read(bytes, 0, req.ContentLength);
            string json = req.ContentEncoding.GetString(bytes);
            return SmartObject.Parse(json);
        }
    }
}